﻿@using System.IO
@using Microsoft.AspNetCore.Components.Web.Media
@using Microsoft.AspNetCore.Components.Web
@implements IAsyncDisposable

<h3>Video Component Tests</h3>

<div>
    <h4>Test Controls</h4>
    <button id="load-mp4" @onclick="LoadMp4">Load MP4</button>
    <button id="change-video" @onclick="ChangeDynamicVideoSource">Change Dynamic Video Source</button>
    <button id="load-templated-video" @onclick="LoadTemplatedVideo">Load Templated Video</button>
    <div id="test-status">Status: <span id="current-status">@_currentStatus</span></div>
</div>

@if (_mp4Visible)
{
    <h4>MP4 basic</h4>
    <Video @ref="@_mp4Ref" id="mp4-basic" Source="@_mp4Source" controls />
}
@if (_dynamicVideoVisible)
{
    <h4>Dynamic Video</h4>
    <Video @ref="@_dynamicVideoRef" id="dynamic-video" Source="@_dynamicVideoSource" controls muted loop />
}
@if (_templatedVideoVisible)
{
    <h4>Templated Video</h4>
    <Video @ref="_templatedVideoComponent" Source="@_templatedVideoSource" Context="vctx">
        <div id="templated-video-container" class="video-shell @(vctx.IsLoading ? "loading" : vctx.HasError ? "error" : "ready")">
            <video id="templated-video" @ref="vctx.Element" playsinline muted loop controls src="@(vctx.ObjectUrl)" data-role="templated-video"></video>
            <span id="templated-video-status">@(vctx.IsLoading ? "Loading" : vctx.HasError ? "Error" : vctx.ObjectUrl is not null ? "Loaded" : "Idle")</span>
        </div>
    </Video>
}

@code {
    private Video _mp4Ref;
    private Video _dynamicVideoRef;
    private Video _templatedVideoComponent;

    private MediaSource _mp4Source = new MediaSource(new byte[0], string.Empty, string.Empty);
    private MediaSource _dynamicVideoSource = new MediaSource(new byte[0], string.Empty, string.Empty);
    private MediaSource _templatedVideoSource = new MediaSource(new byte[0], string.Empty, string.Empty);

    private bool _mp4Visible;
    private bool _dynamicVideoVisible;
    private bool _isShowingFirst = true;
    private string _currentStatus = "Ready";
    private bool _templatedVideoVisible;

    // 1024x1024 green square for 10s mp4
    private static readonly byte[] TestMp4Data = Convert.FromBase64String("AAAAIGZ0eXBpc29tAAACAGlzb21p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JkAQ0AeYAxQBxAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAADAAAbMQAAACdBmiRsQ7/+qZYAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMABKwAAAAkQZ5CeIX/AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGeYXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnmNqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZpoSahBaJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGehkURLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGepXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBnqdqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZqsSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGeykUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGe6XRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnutqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZrwSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGfDkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGfLXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBny9qQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZs0SahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGfUkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGfcXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBn3NqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZt4SahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGflkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWUAAAAJAGftXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBn7dqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZu8SahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGf2kUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGf+XRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBn/tqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZvgSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGeHkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWUAAAAJAGePXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnj9qQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZokSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGeQkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGeYXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnmNqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZpoSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGehkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGepXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBnqdqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZqsSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGeykUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGe6XRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnutqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZrwSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGfDkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGfLXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBny9qQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZs0SahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGfUkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGfcXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBn3NqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZt4SahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGflkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWUAAAAJAGftXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBn7dqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZu8SahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGf2kUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGf+XRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBn/tqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZvgSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGeHkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWUAAAAJAGePXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnj9qQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZokSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGeQkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGeYXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnmNqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZpoSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGehkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGepXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBnqdqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZqsSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGeykUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGe6XRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnutqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZrwSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGfDkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGfLXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBny9qQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZs0SahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGfUkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGfcXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBn3NqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZt4SahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGflkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWUAAAAJAGftXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBn7dqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZu8SahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGf2kUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGf+XRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBn/tqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZvgSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGeHkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWUAAAAJAGePXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnj9qQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZokSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGeQkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGeYXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnmNqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZpoSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGehkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGepXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBnqdqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZqsSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGeykUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGe6XRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnutqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZrwSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGfDkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGfLXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBny9qQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZs0SahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGfUkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGfcXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBn3NqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZt4SahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGflkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWUAAAAJAGftXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBn7dqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZu8SahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGf2kUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGf+XRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBn/tqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZvgSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGeHkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWUAAAAJAGePXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnj9qQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZokSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGeQkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGeYXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnmNqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZpoSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGehkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGepXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBnqdqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZqsSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGeykUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGe6XRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnutqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZrwSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGfDkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGfLXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBny9qQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZs0SahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGfUkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGfcXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBn3NqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZt4SahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGflkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWUAAAAJAGftXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBn7dqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZu8SahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGf2kUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGf+XRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBn/tqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZvgSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGeHkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWUAAAAJAGePXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnj9qQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZokSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGeQkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGeYXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnmNqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZpoSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGehkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGepXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBnqdqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZqsSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGeykUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGe6XRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnutqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZrwSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGfDkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGfLXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBny9qQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZs0SahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGfUkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGfcXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBn3NqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZt4SahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGflkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWUAAAAJAGftXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBn7dqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZu8SahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGf2kUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGf+XRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBn/tqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZvgSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGeHkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWUAAAAJAGePXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnj9qQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZokSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGeQkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGeYXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnmNqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZpoSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGehkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGepXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBnqdqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZqsSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGeykUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGe6XRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnutqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZrwSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGfDkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGfLXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBny9qQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZs0SahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGfUkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGfcXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBn3NqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZt4SahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGflkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWUAAAAJAGftXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBn7dqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZu8SahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGf2kUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGf+XRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBn/tqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZvgSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGeHkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWUAAAAJAGePXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnj9qQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZokSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGeQkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGeYXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnmNqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3UAAAAtQZpoSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAAStAAAAJkGehkUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGepXRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdQAAACQBnqdqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZqsSahBbJlMCHf//qmWAAADAAADAAADAAADAAADAAADAAADAAADAAADAASsAAAAJkGeykUVLC//AAADAAADAAADAAADAAADAAADAAADAAADAAADAAWVAAAAJAGe6XRCvwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAAAwAHdAAAACQBnutqQr8AAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAAAMAB3QAAAAtQZrwSahBbJlMCG///qeEAAADAAADAAADAAADAAADAAADAAADAAADAAADAAk5AAAAJkGfDkUVLC//AAADAAADAAADAAADAAADAAADAAADAAAD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AAoAAAAKAAAADEAAAAqAAAAKAAAACgAAAAxAAAAKgAAACgAAAAoAAAAMQAAACoAAAAoAAAAKAAAADEAAAAqAAAAKAAAACgAAAAxAAAAKgAAACgAAAAoAAAAMQAAACoAAAAoAAAAKAAAADEAAAAUc3RjbwAAAAAAAAABAAAAMAAAAGF1ZHRhAAAAWW1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAALGlsc3QAAAAkqXRvbwAAABxkYXRhAAAAAQAAAABMYXZmNjEuNy4xMDA=");

    private void LoadMp4()
    {
        _mp4Source = new MediaSource(TestMp4Data, "video/mp4", "test-mp4-basic");
        _mp4Visible = true;
        _currentStatus = "MP4 basic loaded";
    }

    private void ChangeDynamicVideoSource()
    {
        if (!_dynamicVideoVisible)
        {
            _dynamicVideoSource = new MediaSource(TestMp4Data, "video/mp4", "dynamic-mp4-a");
            _dynamicVideoVisible = true;
            _isShowingFirst = true;
            _currentStatus = "Dynamic video initialized (A)";
        }
        else
        {
            if (_isShowingFirst)
            {
                _dynamicVideoSource = new MediaSource(TestMp4Data, "video/mp4", "dynamic-mp4-b");
                _currentStatus = "Dynamic video changed to B";
            }
            else
            {
                _dynamicVideoSource = new MediaSource(TestMp4Data, "video/mp4", "dynamic-mp4-a");
                _currentStatus = "Dynamic video changed to A";
            }
            _isShowingFirst = !_isShowingFirst;
        }
    }

    private void LoadTemplatedVideo()
    {
        _templatedVideoSource = new MediaSource(TestMp4Data, "video/mp4", "templated-mp4");
        _templatedVideoVisible = true;
        _currentStatus = "Templated video loaded";
    }

    public async ValueTask DisposeAsync()
    {
        if (_mp4Ref != null) await _mp4Ref.DisposeAsync();
        if (_dynamicVideoRef != null) await _dynamicVideoRef.DisposeAsync();
    if (_templatedVideoComponent != null) await _templatedVideoComponent.DisposeAsync();
    }
}
